package com.ruoyi.order.service.impl;

import java.util.List;
import java.util.concurrent.atomic.AtomicLong;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.order.domain.VerOrderDetail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.order.mapper.VerOrderMapper;
import com.ruoyi.order.domain.VerOrder;
import com.ruoyi.order.service.IVerOrderService;

/**
 * 订单Service业务层处理
 *
 * @author ruoyi
 * @date 2025-08-21
 */
@Service
public class VerOrderServiceImpl implements IVerOrderService
{
    @Autowired
    private VerOrderMapper verOrderMapper;
    private AtomicLong idGenerator = new AtomicLong();

    /**
     * 查询订单
     *
     * @param orderId 订单主键
     * @return 订单
     */
    @Override
    public VerOrder selectVerOrderByOrderId(Long orderId)
    {
        return verOrderMapper.selectVerOrderByOrderId(orderId);
    }

    /**
     * 查询订单列表
     *
     * @param verOrder 订单
     * @return 订单
     */
    @Override
    public List<VerOrder> selectVerOrderList(VerOrder verOrder)
    {
        return verOrderMapper.selectVerOrderList(verOrder);
    }

    /**
     * 新增订单
     *
     * @param verOrder 订单
     * @return 结果
     */
    @Override
    public int insertVerOrder(VerOrder verOrder)
    {
        verOrder.setOrderId(idGenerator.getAndIncrement());
        verOrder.setCreateTime(DateUtils.getNowDate());
        return verOrderMapper.insertVerOrder(verOrder);
    }

    /**
     * 修改订单
     *
     * @param verOrder 订单
     * @return 结果
     */
    @Override
    public int updateVerOrder(VerOrder verOrder)
    {
        return verOrderMapper.updateVerOrder(verOrder);
    }

    /**
     * 批量删除订单
     *
     * @param orderIds 需要删除的订单主键
     * @return 结果
     */
    @Override
    public int deleteVerOrderByOrderIds(Long[] orderIds)
    {
        return verOrderMapper.deleteVerOrderByOrderIds(orderIds);
    }

    /**
     * 删除订单信息
     *
     * @param orderId 订单主键
     * @return 结果
     */
    @Override
    public int deleteVerOrderByOrderId(Long orderId)
    {
        return verOrderMapper.deleteVerOrderByOrderId(orderId);
    }

    @Override
    public VerOrderDetail selectVerOrderDetailByOrderId(Long orderId) {
        return verOrderMapper.selectVerOrderDetailByOrderId(orderId);
    }
}
